from cryptography.hazmat.primitives.asymmetric import rsa, padding
from cryptography.hazmat.primitives import hashes

def verify_signature(model, signature, public_key):
    """
    验证模型签名
    :param model: 模型参数
    :param signature: 签名
    :param public_key: 公钥
    :return: 是否验证通过
    """
    try:
        public_key.verify(
            signature,
            model,
            padding.PSS(
                mgf=padding.MGF1(hashes.SHA256()),
                salt_length=padding.PSS.MAX_LENGTH
            ),
            hashes.SHA256()
        )
        return True
    except:
        return False

# 示例
public_key = private_key.public_key()
is_verified = verify_signature(model, signature, public_key)
print(f"Signature verified: {is_verified}")